package cn.bingo.yunsj.common.result;

import cn.bingo.yunsj.common.StateCode;
import cn.bingo.yunsj.common.exception.CommonException;
import lombok.Data;

import java.util.List;

/**
 * 根据layui规则去写
 */
@Data
public class Response <T>{

    private Integer code;

    private String msg;

    private Long count;

    private List<T> data;

    public Response(Integer status, String message, Long total, List<T> data) {
        this.code = status;
        this.msg = message;
        this.count = total;
        this.data = data;
    }

    public Response(StateCode stateCode, Long total, List<T> data) {
        this.code = stateCode.getCode();
        this.msg = stateCode.getMessage();
        this.count = total;
        this.data = data;
    }

    public Response(StateCode stateCode) {
        this.code = stateCode.getCode();
        this.msg = stateCode.getMessage();
    }

    public Response(StateCode stateCode,String message) {
        this.code = stateCode.getCode();
        this.msg = message;
    }

    public Response(CommonException e) {
        this.code = e.getErrCode();
        this.msg = e.getErrMessage();
    }

    public Response(){

    }

    public Response(Integer status, String message) {
        this.code = status;
        this.msg = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
